package com.we.service.impl;

import com.we.dao.CommentDao;
import com.we.entity.Comment;
import com.we.service.CommentService;
import com.we.util.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @Description 评论业务逻辑接口实现类
 * @Author cr7
 * @Date 20:47
 * @Version V1.0
 */
public class CommentServiceImpl implements CommentService {

    private SqlSession session = MybatisUtils.getSqlSession();
    private CommentDao dao = session.getMapper(CommentDao.class);

    /**
     * 根据笔记id查询评论信息功能实现
     * @param noteID
     * @return
     */
    @Override
    public List<Comment> findCommentById(int noteID) {
        return dao.findCommentById(noteID);
    }

    /**
     * 保存用户评论功能实现
     * @param noteID
     * @param userName
     * @param commentContent
     * @param nickname
     * @return
     */
    @Override
    public int saveComment(int noteID, String userName, String commentContent, String nickname) {
        return dao.saveComment(noteID,userName,commentContent,nickname);
    }
}
